package com.example.music.config;

import com.example.music.utils.ContentValue;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class RMConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //歌手头像地址
        registry.addResourceHandler("/img/singerPic/**")
                .addResourceLocations("file:"+ ContentValue.userDir+
                        ContentValue.Slash+"img"+ContentValue.Slash+
                        "singerPic"+ContentValue.Slash);
        //歌单图片地址
        registry.addResourceHandler("/img/songListPic/**").addResourceLocations(
                "file:"+ContentValue.userDir+ContentValue.Slash+"img"
                        +ContentValue.Slash+"songListPic"+ContentValue.Slash
        );
        //歌曲图片地址
        registry.addResourceHandler("/img/songPic/**").addResourceLocations(
                "file:"+ContentValue.userDir+ContentValue.Slash+"img"
                        +ContentValue.Slash+"songPic"+ContentValue.Slash
        );
        //歌曲地址
        registry.addResourceHandler("/song/**").addResourceLocations(
                "file:"+ContentValue.userDir+ContentValue.Slash+"song"+ContentValue.Slash
        );
        //前端用户头像地址
        registry.addResourceHandler("/avatorImages/**").addResourceLocations(
                "file:"+ContentValue.userDir+ContentValue.Slash+"avatorImages"+ContentValue.Slash
        );
        //用户头像默认地址
        registry.addResourceHandler("/img/**").addResourceLocations(
                "file:"+ContentValue.userDir+ContentValue.Slash+"img"+ContentValue.Slash
        );
    }
}
